package com.zwh.rocketmq.config;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * RocketMQ注册拦截，自行注册，加快容器启动速度
 * 原文链接：https://zhuanlan.zhihu.com/p/568151876
 * @author tianxincoord@163.com
 * @since 2022/8/15
 */
//@Component
//@Aspect
//@Order(1)
@Slf4j
public class RocketMqSkipRegisterAop {
    /**
     * 通过切入afterSingletonsInstantiated拦截注册
     */
    @Around("execution(* org.apache.rocketmq.spring.autoconfigure.ListenerContainerConfiguration.afterSingletonsInstantiated())")
    public Object init(ProceedingJoinPoint joinPoint) {
        log.info("RocketMQ开启代理，默认注册已跳过");
        /// 不调用原生执行方法，直接返回null，跳过方法调用
        // Object proceed = joinPoint.proceed();
        // return proceed
        return null;
    }
}
